package programmercarl.动态规划.C42;

import java.util.Arrays;

class Solution {
    public int findLengthOfLCIS(int[] nums) {
        if (nums.length==0) return -1;
        if (nums.length==1) return nums[0];
        int slow = 0, fast = 1;
        int len=nums.length;
        int maxLen=1;
        while (fast<nums.length){
            if(nums[fast]>nums[fast-1]){
                int currenLen=fast-slow+1;
                maxLen = Math.max(currenLen, maxLen);
            }else {
                slow=fast;
            }
            fast++;
        }
        return maxLen;
    }

    //dp
    public int findLengthOfLCIS_DP(int[] nums) {
            if (nums.length==0) return -1;
            if (nums.length==1) return nums[0];
            int[] dp=new int[nums.length];
            Arrays.fill(dp,1);
            int res=1;
            for (int i = 1; i < nums.length; i++) {
                if (nums[i]>nums[i-1]){
                    dp[i]=dp[i-1]+1;
                }
                res = Math.max(res, dp[i]);
            }

            return res;
    }
}